package com.yangchuang.openpicture.config;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisConfiguration {
    //创建一个mybatisplus的拦截器的实例，交给spring容器管理
    @Bean
    public MybatisPlusInterceptor MyMybatisPlusInterceptor(){
        //创建一个MybatisPlus的拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //对这个拦截器添加分页拦截器 其中DbType.MYSQL 指明 拦截器操作的数据库类型是Mysql数据库
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
